import { createRouter, createWebHistory } from 'vue-router'
import routers from'./routers.js'
// import {useStateStore} from "@/stores/StateStore.js";
const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: [
    {
      path: '/',
      name: 'layout',
      component: ()=>import('../views/LayoutView.vue'),
      redirect: '/home',
      children: routers
    },
    {
      path:'/error',
      name:'error',
      component:()=>import('../views/ErrorView.vue'),
    },
    {
      path:'/404',
      name:'404',
      component:()=>import('../views/404View.vue'),
    },
    {
      path:'/personal',
      name:'personal',
      component:()=>import('../views/PersonalView.vue'),
    },
    {
      path:'/login',
      name:'login',
      component:()=>import('../views/LoginView.vue'),
    }
  ],
})
// router.beforeEach((to, from, next) => {
//   const stateStore = useStateStore()
//   if(stateStore.token){
//     console.log(stateStore.token);
//     console.log("have stateStore");
//   }else{
//     console.log("dont have stateStore");
//   }
//   if(to.path === '/login') {
//     next()
//   }else{
//     next({name: 'login'})
//   }
//
// })
export default router
